package sparrowGui.skin
{
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	import sparrowGui.ComponentDraw;
	import sparrowGui.vars.ComponentVars;
	
	public class AlertSkin extends ComponentDraw
	{
		public var txt_alert:TextField;		//提示窗文字文本的名称
		public var txt_input:TextField;		//提示输入文本的名称
		public var posBtn:Sprite;		//默认按钮位置
		private var spacing:int = 2;		//文本和按钮间间距
		private var alertType:int = 0;		//提示窗类型 。0,表示只有提示文字; 1,表示输入文字
		
		public function AlertSkin(type:int=1)
		{
			var vars:ComponentVars = new ComponentVars();
			vars.bgColor = 0xFAFAFA;
			vars.setBorder(1,1,1,1);
			vars.setBorderColor(0xCBCBCB);
			vars.setPadding(5);
			vars.width = 180;
			vars.height = 120;
			
			alertType = type;
			
			super(vars);
			draw();
			
//			forceDraw = true;s
		}
		
		override protected function init():void
		{
			txt_alert = new TextField();
			txt_alert.width = int(style.width)- int(style.paddingLeft) - int(style.paddingRight);
			txt_alert.height = int(style.height/2)- int(style.paddingTop) - int(style.paddingBottom);
			txt_alert.x = style.width/2 - txt_alert.width/2;
			txt_alert.y = int(style.paddingTop);
			
			var tf:TextFormat = (new TextFormat());
			tf.align = "center";
			txt_alert.defaultTextFormat = tf;
			
			addChild(txt_alert);
			
			if(alertType==1){
				txt_input = new TextField();
				txt_input.height = 20;
				txt_input.width = int(style.width)- int(style.paddingLeft) - int(style.paddingRight);
				txt_input.x = style.width/2 - txt_input.width/2;
				txt_input.y = txt_alert.y + txt_alert.height + spacing;
				txt_input.background = true;
				txt_input.border = true;
				txt_input.type = "input";
				txt_input.visible = false;
				addChild(txt_input);
			}
			
			posBtn = new Sprite();
			posBtn.name = "posBtn";
			addChild(posBtn);
			posBtn.x = width/2;
			posBtn.y = style.height - 2;
		}
	}
}